﻿using RabbitMQ.Client;
using System.Text;

namespace JwtAuth
{
    /// <summary>
    /// RabbitMQ 生产者 测试
    /// </summary>
    public class WeatherFanoutProduct
    {
        public static async void Weather()
        {
            using (var connection = await RabbitUtils.GetConnection().CreateConnectionAsync())
            {
                using (var channel = await connection.CreateChannelAsync())
                {
                    //// 发送持久化消息 
                    //var prop = new BasicProperties { Persistent = true };

                    string message = "20度";
                    var body = Encoding.UTF8.GetBytes(message);
                    await channel.BasicPublishAsync("EXCHANGE_WEATHER", "", true, body);
                    Console.WriteLine("天气信息发送成功！");
                }
            }
        }
    }
}
